library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(purrr)
library(tidyr)
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
monthly <- read.csv("data/output_1901-2018M.csv")
season <- read.csv("data/output_1901-2018S.csv")
annual <- read.csv("data/output_1901-2018Y.csv")
all <- read.csv("data/output_1901-2018MSY.csv")
Directly calculated annual variables:
Derived annual variables:
str(annual)
## 'data.frame': 118 obs. of 29 variables:
## $ Year : int 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 ...
## $ X.ID1 : chr "site1" "site1" "site1" "site1" ...
## $ ID2 : chr "region1" "region1" "region1" "region1" ...
## $ Latitude : num 43.2 43.2 43.2 43.2 43.2 ...
## $ Longitude: num -81.9 -81.9 -81.9 -81.9 -81.9 ...
## $ Elevation: int 180 180 180 180 180 180 180 180 180 180 ...
## $ MAT : num 7.4 7.6 7.6 5.9 7.1 8 6.4 7.8 7.5 7.5 ...
## $ MWMT : num 23.1 20.9 20.6 19.7 20.6 22 19.7 21 20.6 21.2 ...
## $ MCMT : num -4.5 -5.6 -6 -9.5 -7.5 -3.8 -4.9 -4.9 -4.7 -6.1 ...
## $ TD : num 27.6 26.5 26.5 29.1 28.1 25.8 24.6 25.9 25.3 27.4 ...
## $ MAP : int 679 802 833 831 828 868 803 793 918 772 ...
## $ MSP : int 303 455 389 374 414 391 327 364 341 320 ...
## $ AHM : num 25.7 21.9 21.1 19.2 20.7 20.8 20.4 22.5 19.1 22.7 ...
## $ SHM : num 76.2 45.9 52.8 52.6 49.9 56.3 60.3 57.9 60.5 66.4 ...
## $ DD_0 : int 725 607 600 947 714 584 632 625 534 654 ...
## $ DD5 : int 2311 2129 2162 2047 2178 2327 1846 2308 2086 2182 ...
## $ DD_18 : int 4159 3964 3960 4549 4182 3938 4372 3959 4028 4037 ...
## $ DD18 : int 350 192 199 194 258 331 172 289 238 250 ...
## $ NFFD : int 186 190 187 174 181 188 144 184 168 190 ...
## $ bFFP : int 130 136 136 132 132 127 138 131 131 134 ...
## $ eFFP : int 280 280 283 277 280 281 272 281 273 282 ...
## $ FFP : int 150 145 147 145 148 154 134 150 142 148 ...
## $ PAS : int 173 124 138 272 174 111 164 198 141 168 ...
## $ EMT : num -30.3 -30.3 -30.3 -30.3 -30.3 -30.3 -30.3 -30.3 -30.3 -30.3 ...
## $ EXT : num 45.5 45.5 45.5 45.5 45.5 45.5 45.5 45.5 45.5 45.5 ...
## $ MAR : int -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 ...
## $ Eref : int 722 732 738 676 694 718 695 737 696 761 ...
## $ CMD : int 314 161 170 184 160 210 232 246 223 288 ...
## $ RH : int 66 67 67 66 66 67 67 66 68 66 ...
Seasonal variables:
Directly calculated seasonal variables:
Derived seasonal variables: - DD_0_wt winter degree-days below 0°C - DD5_wt winter degree-days below 5°C - DD_18_wt winter degree-days below 18°C - DD18_wt winter degree-days below 18°C - NFFD_wt winter number of frost-free days - PAS_wt winter precipitation as snow (mm) - Eref_wt winter Hargreaves reference evaporation (mm) - CMD_wt winter Hargreaves climatic moisture deficit (mm) - RH_wt winter relative humidity (%)
str(season)
## 'data.frame': 118 obs. of 62 variables:
## $ Year : int 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 ...
## $ X.ID1 : chr "site1" "site1" "site1" "site1" ...
## $ ID2 : chr "region1" "region1" "region1" "region1" ...
## $ Latitude : num 43.2 43.2 43.2 43.2 43.2 ...
## $ Longitude: num -81.9 -81.9 -81.9 -81.9 -81.9 ...
## $ Elevation: int 180 180 180 180 180 180 180 180 180 180 ...
## $ Tmax_wt : num -1.7 -1.5 -0.8 -4.4 -3.5 1.4 -1.4 -1.1 0.8 -1.4 ...
## $ Tmax_sp : num 10.6 12.4 13.4 9.2 10.8 10.1 8.8 10.8 9.3 12.7 ...
## $ Tmax_sm : num 26.4 23.5 23.2 24 24.7 25.6 24 25.6 25.2 25.2 ...
## $ Tmax_at : num 14.3 15.5 14.6 14.2 14.9 15.3 12.9 16.4 14.7 14.1 ...
## $ Tmin_wt : num -10 -10 -8.1 -13.1 -11.5 -6.4 -9.7 -8.8 -6.8 -9.3 ...
## $ Tmin_sp : num 0.5 1.7 2.5 0.2 0.2 0 -0.9 1.3 0.3 1.8 ...
## $ Tmin_sm : num 15 12.8 12.9 12.9 14 14.9 12.6 13.5 13.7 13.5 ...
## $ Tmin_at : num 4.5 5.8 4.3 4.1 4.4 5.1 3.9 5.1 4.3 4.4 ...
## $ Tave_wt : num -5.9 -5.7 -4.5 -8.8 -7.5 -2.5 -5.5 -4.9 -3 -5.4 ...
## $ Tave_sp : num 5.6 7.1 8 4.7 5.5 5 4 6.1 4.8 7.3 ...
## $ Tave_sm : num 20.7 18.2 18.1 18.5 19.3 20.2 18.3 19.6 19.5 19.3 ...
## $ Tave_at : num 9.4 10.6 9.5 9.2 9.7 10.2 8.4 10.8 9.5 9.3 ...
## $ PPT_wt : int 192 151 203 217 181 154 197 255 211 225 ...
## $ PPT_sp : int 154 164 175 226 182 178 191 233 254 172 ...
## $ PPT_sm : int 180 281 260 222 260 264 171 240 225 167 ...
## $ PPT_at : int 154 228 198 164 221 243 232 108 196 216 ...
## $ Rad_wt : int -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 ...
## $ Rad_sp : int -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 ...
## $ Rad_sm : int -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 ...
## $ Rad_at : int -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 ...
## $ DD_0_wt : int 574 570 474 805 696 342 552 508 365 542 ...
## $ DD_0_sp : int 107 42 30 126 86 157 77 85 108 27 ...
## $ DD_0_sm : int 0 0 0 0 0 0 0 0 0 0 ...
## $ DD_0_at : int 44 9 43 29 35 29 37 24 14 44 ...
## $ DD5_wt : int 14 12 15 10 10 29 11 15 21 14 ...
## $ DD5_sp : int 311 342 396 299 291 318 160 335 258 318 ...
## $ DD5_sm : int 1442 1213 1206 1241 1320 1402 1224 1340 1331 1321 ...
## $ DD5_at : int 544 562 546 497 549 584 449 618 479 530 ...
## $ DD_18_wt : int 2135 2126 2016 2394 2279 1831 2106 2050 1882 2094 ...
## $ DD_18_sp : int 1154 1019 938 1234 1157 1205 1294 1112 1219 993 ...
## $ DD_18_sm : int 55 141 141 105 82 58 118 72 74 88 ...
## $ DD_18_at : int 815 695 805 829 794 765 897 715 794 815 ...
## $ DD18_wt : int 0 0 0 0 0 0 0 0 0 0 ...
## $ DD18_sp : int 10 10 15 13 10 9 0 12 5 7 ...
## $ DD18_sm : int 304 157 152 153 210 265 147 220 214 216 ...
## $ DD18_at : int 37 25 33 28 38 56 24 58 19 27 ...
## $ NFFD_wt : int 3 2 2 1 1 6 2 2 3 3 ...
## $ NFFD_sp : int 35 34 33 31 32 34 14 33 32 37 ...
## $ NFFD_sm : int 92 92 92 92 92 92 92 92 92 92 ...
## $ NFFD_at : int 56 61 60 50 55 56 36 57 41 59 ...
## $ PAS_wt : int 140 114 134 199 156 56 128 168 101 163 ...
## $ PAS_sp : int 27 4 3 66 16 49 32 22 39 3 ...
## $ PAS_sm : int 0 0 0 0 0 0 0 0 0 0 ...
## $ PAS_at : int 6 1 7 2 6 4 7 2 2 9 ...
## $ Eref_wt : int 0 0 0 0 0 0 0 0 0 0 ...
## $ Eref_sp : int 170 219 230 157 165 176 182 165 157 217 ...
## $ Eref_sm : int 400 362 354 371 372 381 375 401 388 392 ...
## $ Eref_at : int 152 151 153 147 157 160 137 171 151 152 ...
## $ CMD_wt : int 0 0 0 0 0 0 0 0 0 0 ...
## $ CMD_sp : int 65 78 61 35 24 54 27 0 12 45 ...
## $ CMD_sm : int 220 83 94 149 112 118 205 161 163 226 ...
## $ CMD_at : int 29 0 15 0 24 38 0 85 48 17 ...
## $ RH_wt : int 65 65 69 63 66 69 65 68 69 67 ...
## $ RH_sp : int 65 65 65 69 64 66 66 68 69 64 ...
## $ RH_sm : int 66 67 69 67 68 68 66 64 66 65 ...
## $ RH_at : int 68 69 66 67 66 67 70 64 67 68 ...
season_Tmax <- season %>%
select(Year, starts_with("Tmax")) %>%
gather(key = "Season", value = "Tmax", 2:5)
season_Tmax$Season <- as.factor(season_Tmax$Season)
levels(season_Tmax$Season) <- c("Autumn","Summer","Spring","Winter")
season_Tmin <- season %>%
select(Year, starts_with("Tmin")) %>%
gather(key = "Season", value = "Tmin", 2:5)
season_Tmin$Season <- as.factor(season_Tmin$Season)
levels(season_Tmin$Season) <- c("Autumn","Summer","Spring","Winter")
season_Tave <- season %>%
select(Year, starts_with("Tave")) %>%
gather(key = "Season", value = "Tave", 2:5)
season_Tave$Season <- as.factor(season_Tave$Season)
levels(season_Tave$Season) <- c("Autumn","Summer","Spring","Winter")
season_PPT <- season %>%
select(Year, starts_with("PPT")) %>%
gather(key = "Season", value = "PPT", 2:5)
season_PPT$Season <- as.factor(season_PPT$Season)
levels(season_PPT$Season) <- c("Autumn","Summer","Spring","Winter")
season_Rad <- season %>%
select(Year, starts_with("Rad")) %>%
gather(key = "Season", value = "Rad", 2:5)
season_Rad$Season <- as.factor(season_Rad$Season)
levels(season_Rad$Season) <- c("Autumn","Summer","Spring","Winter")
season_Eref <- season %>%
select(Year, starts_with("Eref")) %>%
gather(key = "Season", value = "Eref", 2:5)
season_Eref$Season <- as.factor(season_Eref$Season)
levels(season_Eref$Season) <- c("Autumn","Summer","Spring","Winter")
season_CMD <- season %>%
select(Year, starts_with("CMD")) %>%
gather(key = "Season", value = "CMD", 2:5)
season_CMD$Season <- as.factor(season_CMD$Season)
levels(season_CMD$Season) <- c("Autumn","Summer","Spring","Winter")
season_RH <- season %>%
select(Year, starts_with("RH")) %>%
gather(key = "Season", value = "RH", 2:5)
season_RH$Season <- as.factor(season_RH$Season)
levels(season_RH$Season) <- c("Autumn","Summer","Spring","Winter")
season_tidy <-list(season_Tmax, season_Tmin, season_Tave, season_PPT, season_Rad, season_Eref, season_CMD, season_RH) %>% reduce(full_join)
## Joining, by = c("Year", "Season")
## Joining, by = c("Year", "Season")
## Joining, by = c("Year", "Season")
## Joining, by = c("Year", "Season")
## Joining, by = c("Year", "Season")
## Joining, by = c("Year", "Season")
## Joining, by = c("Year", "Season")
str(season_tidy)
## 'data.frame': 472 obs. of 10 variables:
## $ Year : int 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 ...
## $ Season: Factor w/ 4 levels "Autumn","Summer",..: 4 4 4 4 4 4 4 4 4 4 ...
## $ Tmax : num -1.7 -1.5 -0.8 -4.4 -3.5 1.4 -1.4 -1.1 0.8 -1.4 ...
## $ Tmin : num -10 -10 -8.1 -13.1 -11.5 -6.4 -9.7 -8.8 -6.8 -9.3 ...
## $ Tave : num -5.9 -5.7 -4.5 -8.8 -7.5 -2.5 -5.5 -4.9 -3 -5.4 ...
## $ PPT : int 192 151 203 217 181 154 197 255 211 225 ...
## $ Rad : int -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 ...
## $ Eref : int 0 0 0 0 0 0 0 0 0 0 ...
## $ CMD : int 0 0 0 0 0 0 0 0 0 0 ...
## $ RH : int 65 65 69 63 66 69 65 68 69 67 ...
Primary monthly variables:
Derived monthly variables: - DD_0_01 – DD_0_12 January - December degree-days below 0°C - DD5_01 – DD5_12 January - December degree-days above 5°C - DD_18_01 – DD_18_12 January - December degree-days below 18°C - DD18_01 – DD18_12 January - December degree-days above 18°C - NFFD01 – NFFD12 January - December number of frost-free days - PAS01 – PAS12 January – December precipitation as snow (mm) - Eref01 – Eref12 January – December Hargreaves reference evaporation (mm) - CMD01 – CMD12 January – December Hargreaves climatic moisture deficit (mm) - RH01 – RH12 January – December relative humidity (%)
str(monthly)
## 'data.frame': 118 obs. of 174 variables:
## $ Year : int 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 ...
## $ X.ID1 : chr "site1" "site1" "site1" "site1" ...
## $ ID2 : chr "region1" "region1" "region1" "region1" ...
## $ Latitude : num 43.2 43.2 43.2 43.2 43.2 ...
## $ Longitude: num -81.9 -81.9 -81.9 -81.9 -81.9 ...
## $ Elevation: int 180 180 180 180 180 180 180 180 180 180 ...
## $ Tmax01 : num -0.2 -1.5 -1.3 -5 -3.7 2.9 -1.1 -0.9 0.6 -1 ...
## $ Tmax02 : num -4.5 -2.4 -0.7 -5.6 -4.8 -0.5 -3.1 -3.1 0.9 -1.8 ...
## $ Tmax03 : num 2.5 7 8.2 1.9 4.7 -0.3 5.6 3.6 1.8 9.3 ...
## $ Tmax04 : num 12.2 11.9 12.1 7.6 10.6 13 6.9 10.7 9.9 13.5 ...
## $ Tmax05 : num 17.1 18.3 20 18.3 17.2 17.5 13.9 18 16.2 15.2 ...
## $ Tmax06 : num 24.7 20.9 20.9 23.3 22.9 23.6 22.2 24.9 23.6 23 ...
## $ Tmax07 : num 28.6 26 25.6 24.9 25.5 25.8 25.2 26.9 25.6 27.3 ...
## $ Tmax08 : num 25.9 23.7 23.2 23.9 25.6 27.3 24.6 25.2 26.5 25.4 ...
## $ Tmax09 : num 22.2 20.8 22 21.1 22.8 24.6 20.4 24.9 20.8 21.5 ...
## $ Tmax10 : num 15.6 15 15.7 13.8 15.5 14.6 12.7 16.7 12.7 16.5 ...
## $ Tmax11 : num 5.2 10.7 6 7.8 6.5 6.7 5.7 7.6 10.5 4.4 ...
## $ Tmax12 : num -0.5 -0.5 -2.5 -1.9 1.8 0 0.8 0.9 -1.5 -2 ...
## $ Tmin01 : num -8.1 -9.8 -8.9 -14 -11.3 -4.3 -8.7 -8.8 -7.1 -8.3 ...
## $ Tmin02 : num -13.5 -11.6 -8 -16.1 -14 -10.7 -12.8 -12 -6.8 -11.9 ...
## $ Tmin03 : num -6.2 -2.4 -0.6 -6.2 -6.1 -7.6 -3.6 -5 -5.1 -1.4 ...
## $ Tmin04 : num 1.4 1.4 0.9 -0.6 0.5 1.1 -1.7 0.9 0.1 2.2 ...
## $ Tmin05 : num 6.4 6.2 7.3 7.4 6.2 6.6 2.6 8.1 6.1 4.6 ...
## $ Tmin06 : num 12.4 10.3 10.2 12.3 12.1 13.2 11.1 12 12.4 11 ...
## $ Tmin07 : num 17.6 15.7 15.5 14.4 15.7 14.8 14.2 15.2 14 15.2 ...
## $ Tmin08 : num 14.9 12.3 13.1 12.1 14.3 16.7 12.4 13.2 14.7 14.2 ...
## $ Tmin09 : num 11.3 10.4 10.7 10.9 11 12 11.2 11.6 9.4 9.8 ...
## $ Tmin10 : num 4.6 4.6 5.6 3.7 4.4 4.6 2 4.7 2.6 5.3 ...
## $ Tmin11 : num -2.5 2.3 -3.4 -2.2 -2.2 -1.2 -1.5 -1 1.1 -1.8 ...
## $ Tmin12 : num -8.6 -7.5 -9.4 -9.1 -4.3 -7.6 -5.6 -6.4 -7.8 -10.3 ...
## $ Tave01 : num -4.2 -5.6 -5.1 -9.5 -7.5 -0.7 -4.9 -4.9 -3.2 -4.7 ...
## $ Tave02 : num -9 -7 -4.3 -10.9 -9.4 -5.6 -8 -7.5 -3 -6.8 ...
## $ Tave03 : num -1.9 2.3 3.8 -2.2 -0.7 -3.9 1 -0.7 -1.7 3.9 ...
## $ Tave04 : num 6.8 6.6 6.5 3.5 5.6 7 2.6 5.8 5 7.9 ...
## $ Tave05 : num 11.8 12.2 13.6 12.9 11.7 12.1 8.3 13.1 11.1 9.9 ...
## $ Tave06 : num 18.5 15.6 15.6 17.8 17.5 18.4 16.7 18.5 18 17 ...
## $ Tave07 : num 23.1 20.9 20.6 19.7 20.6 20.3 19.7 21 19.8 21.2 ...
## $ Tave08 : num 20.4 18 18.2 18 19.9 22 18.5 19.2 20.6 19.8 ...
## $ Tave09 : num 16.8 15.6 16.4 16 16.9 18.3 15.8 18.3 15.1 15.6 ...
## $ Tave10 : num 10.1 9.8 10.7 8.8 10 9.6 7.4 10.7 7.6 10.9 ...
## $ Tave11 : num 1.3 6.5 1.3 2.8 2.1 2.7 2.1 3.3 5.8 1.3 ...
## $ Tave12 : num -4.5 -4 -6 -5.5 -1.3 -3.8 -2.4 -2.8 -4.7 -6.1 ...
## $ PPT01 : int 53 29 64 82 62 69 91 65 70 82 ...
## $ PPT02 : int 49 31 72 71 53 36 28 100 93 63 ...
## $ PPT03 : int 48 66 39 87 40 55 62 61 57 15 ...
## $ PPT04 : int 40 39 75 70 50 50 65 70 113 69 ...
## $ PPT05 : int 65 59 61 70 91 73 64 102 84 88 ...
## $ PPT06 : int 34 118 93 62 87 97 79 62 73 40 ...
## $ PPT07 : int 88 131 86 85 103 90 72 93 103 69 ...
## $ PPT08 : int 57 32 80 76 70 76 20 85 48 57 ...
## $ PPT09 : int 58 114 69 82 62 54 92 22 33 66 ...
## $ PPT10 : int 46 71 74 51 83 128 63 42 50 74 ...
## $ PPT11 : int 49 43 56 32 75 61 77 44 113 76 ...
## $ PPT12 : int 91 68 64 66 50 78 91 47 80 73 ...
## $ Rad01 : num -9999 -9999 -9999 -9999 -9999 ...
## $ Rad02 : num -9999 -9999 -9999 -9999 -9999 ...
## $ Rad03 : num -9999 -9999 -9999 -9999 -9999 ...
## $ Rad04 : num -9999 -9999 -9999 -9999 -9999 ...
## $ Rad05 : num -9999 -9999 -9999 -9999 -9999 ...
## $ Rad06 : num -9999 -9999 -9999 -9999 -9999 ...
## $ Rad07 : num -9999 -9999 -9999 -9999 -9999 ...
## $ Rad08 : num -9999 -9999 -9999 -9999 -9999 ...
## $ Rad09 : num -9999 -9999 -9999 -9999 -9999 ...
## $ Rad10 : num -9999 -9999 -9999 -9999 -9999 ...
## $ Rad11 : num -9999 -9999 -9999 -9999 -9999 ...
## $ Rad12 : num -9999 -9999 -9999 -9999 -9999 ...
## $ DD_0_01 : int 157 195 180 296 243 79 175 175 133 169 ...
## $ DD_0_02 : int 254 212 145 307 263 176 233 223 114 207 ...
## $ DD_0_03 : int 101 36 24 107 77 152 51 77 97 23 ...
## $ DD_0_04 : int 6 6 6 18 9 5 25 8 11 4 ...
## $ DD_0_05 : int 0 0 0 0 0 0 1 0 0 0 ...
## $ DD_0_06 : int 0 0 0 0 0 0 0 0 0 0 ...
## $ DD_0_07 : int 0 0 0 0 0 0 0 0 0 0 ...
## $ DD_0_08 : int 0 0 0 0 0 0 0 0 0 0 ...
## $ DD_0_09 : int 0 0 0 0 0 0 0 0 0 0 ...
## $ DD_0_10 : int 1 1 1 2 1 2 4 1 3 1 ...
## $ DD_0_11 : int 42 8 42 27 33 27 33 23 10 43 ...
## $ DD_0_12 : int 163 149 202 189 87 143 110 118 166 207 ...
## $ DD5_01 : int 6 4 5 3 3 14 4 5 7 5 ...
## $ DD5_02 : int 2 2 5 2 2 3 1 2 6 3 ...
## $ DD5_03 : int 12 31 46 13 16 5 20 13 9 49 ...
## $ DD5_04 : int 87 82 79 39 65 89 27 67 54 109 ...
## $ DD5_05 : int 212 229 271 247 211 224 113 254 195 160 ...
## $ DD5_06 : int 405 318 316 384 374 401 350 403 389 360 ...
## $ DD5_07 : int 560 492 482 454 484 475 456 497 459 503 ...
## $ DD5_08 : int 478 403 408 403 462 525 419 440 484 458 ...
## $ DD5_09 : int 353 319 341 330 357 399 325 398 304 319 ...
## $ DD5_10 : int 168 160 184 133 164 154 99 183 105 189 ...
## $ DD5_11 : int 22 84 21 34 28 31 25 37 70 22 ...
## $ DD5_12 : int 6 6 4 5 13 6 9 8 5 4 ...
## $ DD_18_01 : int 688 733 716 851 791 580 710 710 659 703 ...
## $ DD_18_02 : int 751 697 621 804 763 657 723 710 583 692 ...
## $ DD_18_03 : int 618 488 442 627 581 682 529 582 612 438 ...
## $ DD_18_04 : int 336 342 347 436 374 331 462 366 391 304 ...
## $ DD_18_05 : int 201 188 149 171 202 192 302 165 216 251 ...
## $ DD_18_06 : int 37 90 92 47 53 39 68 38 45 61 ...
## $ DD_18_07 : int 3 10 12 18 11 13 17 9 17 8 ...
## $ DD_18_08 : int 14 40 38 40 18 7 33 25 13 19 ...
## $ DD_18_09 : int 70 94 78 86 68 46 90 46 106 94 ...
## [list output truncated]
monthly_Tmax <- monthly %>%
select(Year, starts_with("Tmax")) %>%
gather(key = "Month", value = "Tmax", 2:13)
monthly_Tmax$Month <- as.factor(monthly_Tmax$Month)
levels(monthly_Tmax$Month) <- c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12")
monthly_Tmin <- monthly %>%
select(Year, starts_with("Tmin")) %>%
gather(key = "Month", value = "Tmin", 2:13)
monthly_Tmin$Month <- as.factor(monthly_Tmin$Month)
levels(monthly_Tmin$Month) <- c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12")
monthly_Tave <- monthly %>%
select(Year, starts_with("Tave")) %>%
gather(key = "Month", value = "Tave", 2:13)
monthly_Tave$Month <- as.factor(monthly_Tave$Month)
levels(monthly_Tave$Month) <- c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12")
monthly_PPT <- monthly %>%
select(Year, starts_with("PPT")) %>%
gather(key = "Month", value = "PPT", 2:13)
monthly_PPT$Month <- as.factor(monthly_PPT$Month)
levels(monthly_PPT$Month) <- c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12")
monthly_Rad <- monthly %>%
select(Year, starts_with("Rad")) %>%
gather(key = "Month", value = "Rad", 2:13)
monthly_Rad$Month <- as.factor(monthly_Rad$Month)
levels(monthly_Rad$Month) <- c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12")
monthly_Eref <- monthly %>%
select(Year, starts_with("Eref")) %>%
gather(key = "Month", value = "Eref", 2:13)
monthly_Eref$Month <- as.factor(monthly_Eref$Month)
levels(monthly_Eref$Month) <- c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12")
monthly_CMD <- monthly %>%
select(Year, starts_with("CMD")) %>%
gather(key = "Month", value = "CMD", 2:13)
monthly_CMD$Month <- as.factor(monthly_CMD$Month)
levels(monthly_CMD$Month) <- c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12")
monthly_RH <- monthly %>%
select(Year, starts_with("RH")) %>%
gather(key = "Month", value = "RH", 2:13)
monthly_RH$Month <- as.factor(monthly_RH$Month)
levels(monthly_RH$Month) <- c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12")
monthly_tidy <- list(monthly_Tmax, monthly_Tmin, monthly_Tave, monthly_PPT, monthly_Rad, monthly_Eref, monthly_CMD, monthly_RH) %>% reduce(full_join)
## Joining, by = c("Year", "Month")
## Joining, by = c("Year", "Month")
## Joining, by = c("Year", "Month")
## Joining, by = c("Year", "Month")
## Joining, by = c("Year", "Month")
## Joining, by = c("Year", "Month")
## Joining, by = c("Year", "Month")
str(monthly_tidy)
## 'data.frame': 1416 obs. of 10 variables:
## $ Year : int 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 ...
## $ Month: Factor w/ 12 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Tmax : num -0.2 -1.5 -1.3 -5 -3.7 2.9 -1.1 -0.9 0.6 -1 ...
## $ Tmin : num -8.1 -9.8 -8.9 -14 -11.3 -4.3 -8.7 -8.8 -7.1 -8.3 ...
## $ Tave : num -4.2 -5.6 -5.1 -9.5 -7.5 -0.7 -4.9 -4.9 -3.2 -4.7 ...
## $ PPT : int 53 29 64 82 62 69 91 65 70 82 ...
## $ Rad : num -9999 -9999 -9999 -9999 -9999 ...
## $ Eref : int 0 0 0 0 0 0 0 0 0 0 ...
## $ CMD : int 0 0 0 0 0 0 0 0 0 0 ...
## $ RH : int 67 66 68 62 68 72 68 67 69 70 ...
ggplot() +
geom_line(data=annual, aes(x=Year, y=MAT), colour = "darkgreen") +
xlab("Year") +
ylab("Mean Annual Temperature (°C)") +
scale_x_continuous(limits = c(1900, 2020), breaks=seq(1900,2020,10)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
ggplot() +
geom_line(data=annual, aes(x=Year, y=MAP), colour = "darkgreen") +
#Aesthetics
xlab("Year") +
ylab("Mean Annual Precipitation (mm)") +
scale_x_continuous(breaks=seq(1900,2020,10)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
ggplot() +
geom_line(data=annual, aes(x=Year, y=MSP), colour = "darkgreen") +
xlab("Year") +
ylab("May to September Precipitation (mm)") +
scale_x_continuous(breaks=seq(1900,2020,10)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
ggplot() +
geom_line(data=annual, aes(x=Year, y=PAS), colour = "darkgreen") +
xlab("Year") +
ylab("Precipitation as Snow (mm)") +
scale_x_continuous(breaks=seq(1900,2020,10)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
ggplot() +
geom_line(data=annual, aes(x=Year, y=CMD), colour = "darkgreen") +
xlab("Year") +
ylab("Climate Moisture Defecit") +
scale_x_continuous(breaks=seq(1900,2020,10)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
str(season_tidy)
## 'data.frame': 472 obs. of 10 variables:
## $ Year : int 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 ...
## $ Season: Factor w/ 4 levels "Autumn","Summer",..: 4 4 4 4 4 4 4 4 4 4 ...
## $ Tmax : num -1.7 -1.5 -0.8 -4.4 -3.5 1.4 -1.4 -1.1 0.8 -1.4 ...
## $ Tmin : num -10 -10 -8.1 -13.1 -11.5 -6.4 -9.7 -8.8 -6.8 -9.3 ...
## $ Tave : num -5.9 -5.7 -4.5 -8.8 -7.5 -2.5 -5.5 -4.9 -3 -5.4 ...
## $ PPT : int 192 151 203 217 181 154 197 255 211 225 ...
## $ Rad : int -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 ...
## $ Eref : int 0 0 0 0 0 0 0 0 0 0 ...
## $ CMD : int 0 0 0 0 0 0 0 0 0 0 ...
## $ RH : int 65 65 69 63 66 69 65 68 69 67 ...
ggplot (data = season_tidy, aes(x=Year, y = Tave, col= Season)) +
geom_line() +
theme_classic()
ggplot (data = season_tidy, aes(x=Year, y = PPT, col= Season)) +
geom_line() +
facet_grid(Season~.) +
theme_classic()
ggplot (data = season_tidy, aes(x=Year, y = CMD, col= Season)) +
geom_line() +
theme_classic()
str(season_tidy)
## 'data.frame': 472 obs. of 10 variables:
## $ Year : int 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 ...
## $ Season: Factor w/ 4 levels "Autumn","Summer",..: 4 4 4 4 4 4 4 4 4 4 ...
## $ Tmax : num -1.7 -1.5 -0.8 -4.4 -3.5 1.4 -1.4 -1.1 0.8 -1.4 ...
## $ Tmin : num -10 -10 -8.1 -13.1 -11.5 -6.4 -9.7 -8.8 -6.8 -9.3 ...
## $ Tave : num -5.9 -5.7 -4.5 -8.8 -7.5 -2.5 -5.5 -4.9 -3 -5.4 ...
## $ PPT : int 192 151 203 217 181 154 197 255 211 225 ...
## $ Rad : int -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 ...
## $ Eref : int 0 0 0 0 0 0 0 0 0 0 ...
## $ CMD : int 0 0 0 0 0 0 0 0 0 0 ...
## $ RH : int 65 65 69 63 66 69 65 68 69 67 ...
w_tempNA <- ggplot() +
geom_line(data=(season_tidy %>% filter(Season == "Winter")), aes(x = Year, y = Tave)) +
xlab("Year") + ylab("Temperature (°C)") + ggtitle("Winter") +
scale_x_continuous(limits = c(1900, 2020), breaks=seq(1900,2020,20)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), legend.position = "none")
sp_tempNA <- ggplot() +
geom_line(data=(season_tidy %>% filter(Season == "Spring")), aes(x = Year, y = Tave)) +
xlab("Year") + ylab("Temperature (°C)") + ggtitle("Spring") +
scale_x_continuous(limits = c(1900, 2020), breaks=seq(1900,2020,20)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), legend.position = "none")
su_tempNA <- ggplot() +
geom_line(data=(season_tidy %>% filter(Season == "Summer")), aes(x = Year, y = Tave)) +
xlab("Year") + ylab("Temperature (°C)") + ggtitle("Summer") +
scale_x_continuous(limits = c(1900, 2020), breaks=seq(1900,2020,20)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), legend.position = "none")
au_tempNA <- ggplot() +
geom_line(data=(season_tidy %>% filter(Season == "Autumn")), aes(x = Year, y = Tave)) +
xlab("Year") + ylab("Temperature (°C)") + ggtitle("Autumn") +
scale_x_continuous(limits = c(1900, 2020), breaks=seq(1900,2020,20)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), legend.position = "none")
seasonal_temp_plotNA <- grid.arrange(w_tempNA, sp_tempNA, su_tempNA, au_tempNA, nrow = 2, ncol = 2)
w_precipNA <- ggplot() +
geom_line(data=(season_tidy %>% filter(Season == "Winter")), aes(x = Year, y = PPT)) +
xlab("Year") + ylab("Precipitation (mm)") + ggtitle("Winter") +
scale_x_continuous(limits = c(1900, 2020), breaks=seq(1900,2020,20)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), legend.position = "none")
sp_precipNA <- ggplot() +
geom_line(data=(season_tidy %>% filter(Season == "Spring")), aes(x = Year, y = PPT)) +
xlab("Year") + ylab("Precipitation (mm)") + ggtitle("Spring") +
scale_x_continuous(limits = c(1900, 2020), breaks=seq(1900,2020,20)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), legend.position = "none")
su_precipNA <- ggplot() +
geom_line(data=(season_tidy %>% filter(Season == "Summer")), aes(x = Year, y = PPT)) +
xlab("Year") + ylab("Precipitation (mm)") + ggtitle("Summer") +
scale_x_continuous(limits = c(1900, 2020), breaks=seq(1900,2020,20)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), legend.position = "none")
au_precipNA <- ggplot() +
geom_line(data=(season_tidy %>% filter(Season == "Autumn")), aes(x = Year, y = PPT)) +
xlab("Year") + ylab("Precipitation (mm)") + ggtitle("Autumn") +
scale_x_continuous(limits = c(1900, 2020), breaks=seq(1900,2020,20)) +
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), legend.position = "none")
seasonal_precip_plotNA <- grid.arrange(w_precipNA, sp_precipNA, su_precipNA, au_precipNA, nrow = 2, ncol = 2)
str(monthly_tidy)
## 'data.frame': 1416 obs. of 10 variables:
## $ Year : int 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 ...
## $ Month: Factor w/ 12 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Tmax : num -0.2 -1.5 -1.3 -5 -3.7 2.9 -1.1 -0.9 0.6 -1 ...
## $ Tmin : num -8.1 -9.8 -8.9 -14 -11.3 -4.3 -8.7 -8.8 -7.1 -8.3 ...
## $ Tave : num -4.2 -5.6 -5.1 -9.5 -7.5 -0.7 -4.9 -4.9 -3.2 -4.7 ...
## $ PPT : int 53 29 64 82 62 69 91 65 70 82 ...
## $ Rad : num -9999 -9999 -9999 -9999 -9999 ...
## $ Eref : int 0 0 0 0 0 0 0 0 0 0 ...
## $ CMD : int 0 0 0 0 0 0 0 0 0 0 ...
## $ RH : int 67 66 68 62 68 72 68 67 69 70 ...
ggplot() +
geom_boxplot(data = monthly_tidy, aes(x = Month, y = Tave), alpha = 0.3) +
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
ggplot() +
geom_boxplot(data = monthly_tidy, aes(x = Month, y = PPT), alpha = 0.7) +
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
ggplot() +
geom_boxplot(data = monthly_tidy, aes(x = Month, y = CMD), alpha = 0.7) +
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
ggplot() +
geom_boxplot(data = monthly_tidy, aes(x = Month, y = RH), alpha = 0.7) +
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
ggplot(data = monthly_tidy, aes(x=Year, y = Tave)) +
geom_line() +
facet_grid(Month~.) +
theme_classic()
ggplot(data = monthly_tidy, aes(x=Year, y = PPT)) +
geom_line() +
facet_grid(Month~.) +
theme_classic()
ggplot(data = monthly_tidy, aes(x=Year, y = CMD)) +
geom_line() +
facet_grid(Month~.) +
theme_classic()
NA_p <- monthly_tidy %>%
group_by(Month) %>%
summarize(mean_precip= mean(PPT), sd_precip = sd(PPT), n = n()) #%>%
## `summarise()` ungrouping output (override with `.groups` argument)
NA_p$Month <- as.numeric(NA_p$Month)
NA_p <- NA_p %>% mutate(se_precip = sd_precip / sqrt(n), lower = mean_precip - se_precip, upper = mean_precip + se_precip) %>% round(2)
NA_p
## # A tibble: 12 x 7
## Month mean_precip sd_precip n se_precip lower upper
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 69.0 24.9 118 2.29 66.7 71.2
## 2 2 59.5 24.2 118 2.23 57.2 61.7
## 3 3 61.0 21.1 118 1.95 59.0 62.9
## 4 4 74.8 24.3 118 2.24 72.6 77.1
## 5 5 73.9 29.2 118 2.69 71.2 76.6
## 6 6 77.5 27.7 118 2.55 75.0 80.1
## 7 7 76.0 25.4 118 2.34 73.6 78.3
## 8 8 70.5 30.1 118 2.77 67.7 73.3
## 9 9 75.1 30.8 118 2.83 72.2 77.9
## 10 10 72.4 30.5 118 2.81 69.5 75.2
## 11 11 74.4 26.7 118 2.46 72.0 76.9
## 12 12 68.9 21.8 118 2.01 66.9 70.9
ggplot() +
geom_boxplot(data = monthly_tidy, aes(x = Month, y = Tave), fill = "red3", alpha = 0.7) +
geom_line(data = NA_p, aes(x = Month, y = mean_precip-75), col= "steelblue4", size = 1) +
geom_ribbon(data = NA_p, aes(x = Month, ymin = (lower-75), ymax = (upper-75)), alpha = 0.3, fill= "steelblue4") +
scale_y_continuous("Temperature (°C)", sec.axis = sec_axis(~ . + 75, name = "Precipitation (mm)")) +
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
write.csv(monthly_tidy, "outputs/monthly_tidy.csv")
write.csv(season_tidy, "outputs/season_tidy.csv")
Sys.time()
## [1] "2020-06-22 16:37:00 PDT"
git2r::repository()
## Local: master /Users/JenBaron/Documents/UWO/UWO NSERC/Statistical Analysis/Climate/Climate_Pinery
## Remote: master @ origin (https://github.com/JenBaron/Climate_Pinery.git)
## Head: [ad4302f] 2020-06-19: seasonal climateNA
sessionInfo()
## R version 4.0.0 (2020-04-24)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Catalina 10.15.5
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] gridExtra_2.3 tidyr_1.0.2 purrr_0.3.4 dplyr_1.0.0 ggplot2_3.3.1
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.4.6 git2r_0.26.1 pillar_1.4.4 compiler_4.0.0
## [5] tools_4.0.0 digest_0.6.25 evaluate_0.14 lifecycle_0.2.0
## [9] tibble_3.0.1 gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.6
## [13] cli_2.0.2 yaml_2.2.1 xfun_0.14 withr_2.2.0
## [17] stringr_1.4.0 knitr_1.28 generics_0.0.2 vctrs_0.3.1
## [21] grid_4.0.0 tidyselect_1.1.0 glue_1.4.1 R6_2.4.1
## [25] fansi_0.4.1 rmarkdown_2.1 farver_2.0.3 magrittr_1.5
## [29] scales_1.1.1 ellipsis_0.3.1 htmltools_0.4.0 assertthat_0.2.1
## [33] colorspace_1.4-1 labeling_0.3 utf8_1.1.4 stringi_1.4.6
## [37] munsell_0.5.0 crayon_1.3.4